package com.gosophia.commons.web.action;

import java.util.ArrayList;
import java.util.List;

import com.gosophia.commons.OrderCondition;
import com.gosophia.commons.Page;
import com.gosophia.commons.PropertyFilter;

/**
 * Ajax表格组件通用支持action基类 功能：
 * 
 * @author renxuehui
 * @since 2010-9-19 Copyright (c) 2010 Gosophia corporation All Rights Reserved
 */
public abstract class BaseAjaxAction<T> extends BaseSupportAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7913228896721329522L;

	/**
	 * 查询标记 0:模糊查询；1:高级查询
	 */
	protected Boolean searchType = false;

	/**
	 * 模糊查询条件
	 */
	protected String searchString = "";

	/**
	 * 检索条件 当提交的json格式为如下格式时，不必转换，即可通过此属性进行接收
	 * {"propertyFilters[0].propertyName":"name1",
	 * "propertyFilters[0].operator":"EQ",
	 * "propertyFilters[0].propertyValue":"0",
	 * "propertyFilters[0].propertyValue1":"2",
	 * "propertyFilters[1].propertyName":"name2",
	 * "propertyFilters[1].operator":"BETWEEN",
	 * "propertyFilters[1].propertyValue":"0",
	 * "propertyFilters[1].propertyValue1":"2"}
	 */
	protected List<PropertyFilter> propertyFilters = new ArrayList<PropertyFilter>();

	/**
	 * 排序条件
	 * 
	 * 当提交的json格式为如下格式时，不必转换，即可通过此属性进行接收
	 * {"orderCondition[0].propertyName":"name1",
	 * "orderCondition[0].order":"asc",
	 * "orderCondition[1].propertyName":"name2",
	 * "orderCondition[1].order":"desc"}
	 */
	protected List<OrderCondition> orderConditions = new ArrayList<OrderCondition>();

	/**
	 * 详细信息
	 */
	protected T detailData;

	/**
	 * 分页及数据信息
	 */
	protected Page<T> page = new Page<T>();

	public abstract T getDetailData();

	public Page<T> getPage() {
		return page;
	}

	public void setPropertyFilters(List<PropertyFilter> propertyFilters) {
		this.propertyFilters = propertyFilters;
	}

	public void setOrderConditions(List<OrderCondition> orderConditions) {
		this.orderConditions = orderConditions;
	}

	public List<PropertyFilter> getPropertyFilters() {
		return propertyFilters;
	}

	public void setDetailData(T detailData) {
		this.detailData = detailData;
	}

	public void setPage(Page<T> page) {
		this.page = page;
	}

	public Boolean getSearchType() {
		return searchType;
	}

	public void setSearchType(Boolean searchType) {
		this.searchType = searchType;
	}

	public String getSearchString() {
		return searchString;
	}

	public void setSearchString(String searchString) {
		this.searchString = searchString;
	}

	public List<OrderCondition> getOrderConditions() {
		return orderConditions;
	}
}
